#!/bin/sh

# SPDX-FileCopyrightText: © 2018-2022 Peter Lemenkov
#
# SPDX-License-Identifier: CC0-1.0

. "`dirname "$0"`/../functions"

# Whether we have native reader or the one from ImageMagick?
autotrace -list-input-formats 2>&1 | grep pbm |grep -q "native"
RESULT=$?
if [ $RESULT -eq 0 ] ; then
	skip "github#55: AutoTrace cannot read image from stdin yet if not built against ImageMagick/GraphicsMagic"
fi

DIR=$1
cat $DIR/testrect.pbm | autotrace -report-progress -filter-iterations 0 -error-threshold 1 -centerline -output-format svg -output-file $DIR/testrect.svg -input-format pbm -
diff -q -w --strip-trailing-cr $DIR/testrect.output.svg $DIR/testrect.svg
RESULT=$?

if [ $RESULT -eq 0 ] && [ -s $DIR/testrect.svg ] ; then
    rm -f $DIR/testrect.svg
    ok
else
    fail "$DIR/testrect.output.svg not equal to $DIR/testrect.svg"
fi
